package com.ryskoo.controller.product;

import com.ryskoo.catering.productcate.domain.ProductCategoryPO;
import com.ryskoo.catering.productcate.service.IProductCategoryService;
import com.ryskoo.framework.core.bean.QueryMessageDTO;
import com.ryskoo.framework.core.bean.ReturnMessageDTO;
import com.ryskoo.framework.core.controller.BasicHandler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.Map;

/**
 * 平台推荐分类的设置控制器
 *
 * @author JackHou
 *
 */
@Controller
@RequestMapping("/vendor/cater/productrecommendcate")
public class ProductRecommendCateController extends BasicHandler<ProductCategoryPO> {

    private static final String TEMPLATE_PATH = "system/productrecommendcate";

    private static final String MODULE_NAME = "ProductRecommendCate";
    /**
     * 基类构造方法.
     */
    public ProductRecommendCateController() {
        super(TEMPLATE_PATH, MODULE_NAME);
    }

    private IProductCategoryService productCateService;

    @Autowired
    public void setService(IProductCategoryService productCateService) {
        this.productCateService = productCateService;
        super.setService(productCateService);
    }

    /**
     * 重写分页查询列表，只查询类型为2的分类
     * @param queryMessage 统一查询消息 {@link QueryMessageDTO}
     * @return
     */
    @Override
    public ReturnMessageDTO list(@RequestBody  QueryMessageDTO queryMessage) {
        Map<String,Object> typeConditon = new HashMap<>();
        typeConditon.put("operation","EQ");
        typeConditon.put("value","2");
        Map<String,Map<String,Object>> conditions = queryMessage.getQueryParams();
        conditions.put("type",typeConditon);
        queryMessage.setQueryParams(conditions);
        return super.list(queryMessage);
    }
}
